ShortMessage = {
	addUrl : SKYLINE_DOMAIN + "shortMessage/add.html",
	forwardUrl : SKYLINE_DOMAIN + "shortMessage/forward.html",
	shortMessageTextId : "shortMessageText",
	messageMaxSize:200,
	addShortMessage : function() {
		var text = document.getElementById(ShortMessage.shortMessageTextId).value;
		//alert(text.length);
		$.ajax({
					url : this.addUrl,
					data : "text=" + text ,
					type : "POST",
					dataType : "json",
					contentType : "application/x-www-form-urlencoded;charset=utf-8",
					success : function(result) {
						document
								.getElementById(ShortMessage.shortMessageTextId).value = "";
						ShortMessage.textAreaBlur();
						jAlert("短消息成功发布。", '短消息');
					},
					error : function() {
						jAlert("提交短消息失败。", '短消息');
					}
				});

	},
	forwardShortMessageRequest:function(id){
		var requestContent="";
		
		requestContent+="我想说:<br><textarea row='3' col='56' style='width:320px;' id='forwardShortMessageComment"+id+"'></textarea><br>";
		requestContent+="<input type='button' onclick='ShortMessage.forwardShortMessage("+id+")' value='提交'>";
		requestContent+="<input type='button' onclick='$.alerts._hide();' value='取消'>"
		jMessageBox(requestContent, '短消息');
	},
	forwardShortMessage:function(id){
		var comment=document.getElementById("forwardShortMessageComment"+id).value;
		$.ajax({
			url : this.forwardUrl,
			data : "comment=" + comment+"&id=" +id,
			type : "POST",
			dataType : "json",
			contentType : "application/x-www-form-urlencoded;charset=utf-8",
			success : function(result) {
//				document
//						.getElementById(ShortMessage.shortMessageTextId).value = "";
//				ShortMessage.textAreaBlur();
				$.alerts._hide();
			},
			error : function() {
				jAlert("提交短消息失败。", '短消息');
			}
		});
	},
	insertSmiley:function(smiley){
		document.getElementById(ShortMessage.shortMessageTextId).value+="/"+smiley;
		ShortMessage.textAreaChange();
	},
	textAreaFocus : function() {
		document.getElementById(ShortMessage.shortMessageTextId).style.height = "64px";
		var smileysBox = document.getElementById("smileysBox");
		smileysBox.innerHTML = "";
		for ( var i = 0; i < smileys.length; i++) {
			// smileysBox.innerHTML+=smileys[i];
			var str = "<a title='" + smileysChn[i]
					+ "' href='javascript:ShortMessage.insertSmiley(\"" + smileys[i]
					+ "\")'><img style='border: 1px #eeeeee' src='"
					+ smileysPath + smileys[i]
					+ ".gif' width='24px' height='24px'></a>";
			smileysBox.innerHTML += str;

		}
		smileysBox.style.display = "block";
		
		//alert(document.getElementById("shortMessageText").value.length);
		//alert();
	},
	textAreaChange:function(){
		var shortMessageTextCount=document.getElementById("shortMessageTextCount");
		var shortMessageText=document.getElementById("shortMessageText").value;
		if(shortMessageText.length>this.messageMaxSize)
		{
			//shortMessageText=shortMessageText.substring(this.messageMaxSize)
			//jAlert("提交短消息失败。", '短消息');
			shortMessageTextCount.color="red";
			shortMessageTextCount.innerHTML="您已超过"+(shortMessageText.length-this.messageMaxSize)+"字";
		}else{
			shortMessageTextCount.color="black";
			shortMessageTextCount.innerHTML="您还可输入"+(this.messageMaxSize-shortMessageText.length)+"字";
		}
	},
	textAreaBlur : function() {
		document.getElementById(ShortMessage.shortMessageTextId).style.height = "24px";
		smileysBox.innerHTML = "";
		//document.getElementById("shortMessageTextCount").innerHTML='0';
		smileysBox.style.display = "none";
		this.textAreaChange();
	}
}